<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.bilyet}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            
            <h:form>
                
                <script type="text/javascript">  
                    
                    function handleBilyetApprov(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('#dialog').effect("shake", { times:3 }, 100);  
                            alert("fail");
                        } else {  
                           dlgBilyetApproval.hide();  
                           alert("success");
                        }  
                    }
                </script>  
                
                <p:outputPanel autoUpdate="true">
                <p:toolbar >
                    <p:toolbarGroup align="left">
                        <p:toolbarGroup align="left">    
                        <p:commandButton value="#{bundle.btnOpen}" icon="ui-icon-disk" 
                                        update=":#{utilityBean.findClientId('displayBilyetApproval')}" actionListener="#{bilyetapprovalBean.openData()}"
                                        oncomplete="dlgBilyetApproval.show();"> 
                        </p:commandButton>
                            
                        <p:commandButton value="Refresh" icon="ui-icon-arrowrefresh-1-w" update=":#{utilityBean.findClientId('dtBilyetApproval')}" 
                                         actionListener="#{bilyetapprovalBean.loadSavings()}" >
                        </p:commandButton>
                    </p:toolbarGroup>
                    </p:toolbarGroup>
                </p:toolbar>
                </p:outputPanel>
                
                <p:dataTable id="dtBilyetApproval" value="#{bilyetapprovalBean.bilyets}" var="approve" 
                             selection="#{bilyetapprovalBean.bilyet}" selectionMode="single" rowKey="#{approve.bilyetId}" 
                    rowIndexVar="noUrut" emptyMessage=""
                    paginator="true" rows="10" paginatorPosition="bottom" 
                    paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {NextPageLink}"
                    resizableColumns="true">
                                        
                    <p:column style="width: 10px">
                        <f:facet name="header">No.</f:facet>
                        <h:outputText value="#{noUrut+1}" />
                    </p:column>
                    
                    <p:column style="width: 90px">
                        <f:facet name="header">#{bundle.bilyetNo}</f:facet>
                        <h:outputText value="#{approve.bilyetNo}" />
                    </p:column>

                    <p:column style="width: 90px" >
                        <f:facet name="header">#{bundle.cif}</f:facet>
                        <h:outputText value="#{approve.customer.cif}" />
                    </p:column>
                                        
                    <p:column style="width: 130px" >
                        <f:facet name="header">#{bundle.customer}</f:facet>
                        <h:outputText value="#{approve.customer.customerName}" />
                    </p:column>
                                        
                    <p:column style="width: 80px" >
                        <f:facet name="header">#{bundle.date}</f:facet>
                        <h:outputText value="#{approve.bilyetDate}" />
                    </p:column>
                    
                    <p:column style="width: 130px" >
                        <f:facet name="header">#{bundle.amount}</f:facet>
                        <h:outputText value="#{approve.principleAmount}" styleClass="numPos">
                            <f:convertNumber groupingUsed="true" />
                        </h:outputText>
                    </p:column>
                </p:dataTable>
            </h:form>     
            
            <p:dialog header="Verifikasi Rekening Deposito" widgetVar="dlgBilyetApproval" closable="true" dynamic="true" 
                           appendToBody="true" modal="true" >
                <h:form>        
                    <h:panelGrid id="displayBilyetApproval" styleClass="addELIT" cellpadding="0" 
                                 style="vertical-align: top" columnClasses="panelGridId,panelGridId">
                        
                        <h:panelGrid columns="2" rowClasses="panelGridId" >
                            <p:panel header="#{bundle.bilyetLedgend}" >
                                <h:panelGrid columns="3" cellpadding="0" cellspacing="5">
                                    <h:outputLabel value= "#{bundle.bilyetNo}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.bilyet.bilyetNo}" />

                                    <h:outputLabel value= "#{bundle.bilyetDate}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.bilyet.bilyetDate}" />

                                    <h:outputLabel value="#{bundle.deproduct}" /><h:outputLabel value= ":" />
                                    <p:selectOneMenu value="#{bilyetapprovalBean.bilyet.deproduct.deproductId}" 
                                                style="width: 202px;" disabled="true">
                                        <f:selectItems value="#{bilyetapprovalBean.avblProd}" />
                                    </p:selectOneMenu>

                                    <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.cif}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{bilyetapprovalBean.bilyet.customer.cif}" />

                                    <h:outputLabel value= "#{bundle.aro}" /><h:outputLabel value= ":" />
                                    <p:selectBooleanCheckbox value="#{bilyetapprovalBean.bilyet.aro}" disabled="true"/>

                                    <h:outputLabel value= "#{bundle.parentBilyet}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.bilyetParentNo}" />

                                    <h:outputLabel value= "#{bundle.amount}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.bilyet.principleAmount}" styleClass="numPos">
                                        <f:convertNumber />
                                    </h:outputText> 

                                    <h:outputLabel value="#{bundle.interestRate}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.bilyet.interestRate}" styleClass="numPos">
                                        <f:convertNumber />
                                    </h:outputText> 

                                    <h:outputLabel value= "#{bundle.interestAmount}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.bilyet.interestAmount}" styleClass="numPos">
                                        <f:convertNumber />
                                    </h:outputText> 

                                    <h:outputLabel value= "#{bundle.taxAmount}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.bilyet.taxAmount}" styleClass="numPos">
                                        <f:convertNumber />
                                    </h:outputText> 

                                    <h:outputLabel value= "#{bundle.disbInterestOpt}" /><h:outputLabel value= ":" />
                                    <p:selectOneMenu style="width: 200px;" value="#{bilyetapprovalBean.bilyet.disbInterestOpt}" label="#{bundle.disbInterestOpt}" disabled="true">
                                        <f:selectItems value="#{bilyetapprovalBean.avblDisb}" />
                                    </p:selectOneMenu>

                                    <h:outputLabel value= "#{bundle.bilyetSavdep}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.depSavaccntNO}" />
                                    
                                    <h:outputLabel value= "#{bundle.ownerAccnt}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.depSavaccntOwner}" />

                                    <h:outputLabel value= "#{bundle.balance}" /><h:outputLabel value= ":" />
                                    <h:outputText styleClass="numPos" value="#{bilyetapprovalBean.saldo}" >
                                        <f:convertNumber />
                                    </h:outputText>
                                
                                    <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.bilyetSavaccnt}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{bilyetapprovalBean.accntDest}" />

                                    <h:outputLabel value= "#{bundle.ownerAccnt}" /><h:outputLabel value= ":" />
                                    <h:outputText value="#{bilyetapprovalBean.accntOwner}" />

                                    <h:outputLabel value= "#{bundle.disbOtherBankAccno}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{bilyetapprovalBean.bilyet.disbOtherBankAccno}" />

                                    <h:outputLabel value= "#{bundle.disbOtherBankName}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{bilyetapprovalBean.bilyet.disbOtherBankName}" />

                                    <h:outputLabel value= "#{bundle.disbOtherBankBranch}" /><h:outputLabel value= ":" />
                                    <h:outputText  value="#{bilyetapprovalBean.bilyet.disbOtherBankBranch}" />

                                </h:panelGrid>
                            </p:panel>

                            <h:panelGrid columns="1" cellpadding="1" rowClasses="panelGridId" border="0" >
                                <p:panel header="#{bundle.cusledgen}">
                                    <p:outputPanel autoUpdate="true">
                                    <h:panelGrid columns="3" cellpadding="0" cellspacing="5">

                                        <h:outputLabel value= "#{bundle.globalName}" /><h:outputLabel value= ":" />
                                        <h:outputText style="padding: 0 75px 0 0;"  value="#{bilyetapprovalBean.bilyet.customer.customerName}" />

                                        <h:outputLabel value= "#{bundle.aliasName}" /><h:outputLabel value= ":" />
                                        <h:outputText rendered="true" value="#{bilyetapprovalBean.bilyet.customer.aliasName}" />

                                        <h:outputLabel value= "#{bundle.phone}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{bilyetapprovalBean.bilyet.customer.phone}"/> 

                                        <h:outputLabel value= "#{bundle.mobilePhone}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{bilyetapprovalBean.bilyet.customer.mobilePhone}"/>

                                        <h:outputLabel style="padding: 0 15px 0 0;"  value= "#{bundle.npwp}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{bilyetapprovalBean.bilyet.customer.npwp}" />

                                        <h:outputLabel style="padding: 0 15px 0 0;"  value= "#{bundle.addressRes}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{bilyetapprovalBean.bilyet.customer.idAddressLine1}" />

                                    </h:panelGrid>
                                    </p:outputPanel>
                                </p:panel>

                                <p:panel header="#{bundle.deproduct}" >
                                    <p:outputPanel autoUpdate="true">
                                    <h:panelGrid columns="3" cellpadding="0" cellspacing="5">
                                        <h:outputLabel value= "#{bundle.period}" /><h:outputLabel value= ":" />
                                        <h:outputText value="#{constantaBean.getDeptPeriodText(bilyetapprovalBean.bilyet.deproduct.periodOpt)}" />

                                        <h:outputLabel value= "#{bundle.numOfPeriod}" /><h:outputLabel value= ":" />
                                        <h:outputText styleClass="alignNum" value="#{bilyetapprovalBean.bilyet.deproduct.numOfPeriod}" />
                                    </h:panelGrid>
                                </p:outputPanel>        
                                </p:panel>
                            </h:panelGrid>

                        </h:panelGrid>
                    </h:panelGrid>
                    
                    <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                        <f:facet name="footer">  
                            <p:commandButton value="#{bundle.approved}" icon="ui-icon-disk" actionListener="#{bilyetapprovalBean.approve(true)}"
                                             update=":#{utilityBean.findClientId('dtBilyetApproval')}"      
                                oncomplete="dlgBilyetApproval.hide()"/>  
                            <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgBilyetApproval.hide()" 
                                icon="ui-icon-document" />
                        </f:facet>
                    </h:panelGrid>
                </h:form>
            </p:dialog>   
            
        </ui:composition>    
    </h:body>
</html>